const { DataTypes } = require('sequelize')

const sequelize = require('../db/sequelize')

const User = sequelize.define('user', {
  username: {
    type: DataTypes.STRING,
    allowNull: false,
    unique: true,
    comment: '用户名'
  },
  password: {
    type: DataTypes.CHAR(64),
    allowNull: false,
    comment: '密码'
  },
  isAdmin: {
    type: DataTypes.BOOLEAN,
    allowNull: false,
    defaultValue: 0,
    comment: '是否是管理员, 0代表不是(默认), 1代表是'
  }
}, {
  tableName: 'users',
  charset: 'utf8'
})

// 创建 User 数据表
// User.sync({ force: true })

module.exports = User
